package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Employee;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 员工管理数据访问层
 * @author Asin
 */
public interface EmployeeMapper {

    /**
     * 通过用户名查询员工信息
     * @param employee
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee findEmployeeByUserName(Employee employee);

    /**
     * 查询所有
     */
    List<Employee> findAll(String name);

    /**
     * 新增员工
     * @param employee
     * @return
     */
    @Insert("insert into employee values(null,#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    int addEmployee(Employee employee);

    /**
     * 更新员工
     * @param employee
     * @return
     */
    int updateEmployee (Employee employee);

    /**
     * 根据id查询员工
     * @param id
     * @return
     */
    @Select("select * from employee where id = #{id}")
    Employee findEmployeeById(int id);
}
